<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>离职人员工作交接</title>
    <script src="../../../../../res/js/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="../../../../../res/js/login_common.js" charset="utf-8"></script>
    <script src="../../../../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../../../../res/js/Tools.js" charset="utf-8"></script>
    <script src="../../../../../res/js/error.js" charset="utf-8"></script>
    <link rel="shortcut icon" type="image/x-icon" href="../../../../../res/images/favicon.ico">
    <link rel="stylesheet" href="../../../../../res/layui/css/layui.css" media="all">
    <style type="text/css">
        .connect {
            display: flex;
            align-items: center;
            margin-right: 0px !important;
        }
        .connectone {
            margin-top: 3px !important;
            width: calc(100% - 145px) !important;

        }
    </style>
</head>
<body style="padding: 10px">
<h1 align="center" style="margin-bottom: 20px">离职人员工作交接（行政）</h1>
<form class="layui-form layui-form-pane" action="">

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">行政交接</label>
        <div class="layui-input-block">


            <div class="layui-form-item">
                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">办公用品说明</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               name="handoverOfficeSupplies"
                               id="handoverOfficeSupplies"
                               type="text"/>
                    </div>
                </div>

                <div class="layui-form-item" style="display: flex">
                    <label class="layui-form-label" style="width: 145px">交接人员</label>
                    <div class="layui-input-block" style="margin-top: 1px; width: calc(100% - 145px)">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="handoverReceiver" disabled id="handoverReceiver">
                    </div>
                </div>
                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">公司账号</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required" id="handoverAccountPassword"
                               name="handoverAccountPassword" placeholder="请输入公司相关的登陆账号密码等"
                               type="text"/>
                    </div>
                </div>
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label" style="width: 145px">是否违约</label>
                    <div class="layui-input-block" style="margin-left: 145px">
                        <input type="radio" id="handoverRenege0" name="handoverRenege" value="0" title="是">
                        <input type="radio" id="handoverRenege1" name="handoverRenege" value="1" title="否" checked="">
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">其它</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               name="handoverOthers"
                               id="handoverOthers"
                               type="text"/>
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">本月考勤情况</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               name="attendance"
                               id="attendance"
                               type="text"/>
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">社保停缴时间</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" id="stopPaying" lay-verify="date"
                               name="stopPaying"
                               placeholder="yyyy-MM-dd"
                               type="text">
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">薪资截止日</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" id="payrollDeadline"
                               name="payrollDeadline"
                               placeholder="yyyy-MM-dd "
                               type="text">
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 250px">最终工资结算及发放时间</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" id="paymentTime"
                               name="paymentTime"
                               placeholder="yyyy-MM-dd"
                               type="text">
                    </div>
                </div>

                <div class="layui-form-item" pane="">
                    <label class="layui-form-label" style="width: 145px">开具离职证明</label>
                    <div class="layui-input-block connectone" style="margin-left: 145px;">
                        <input type="radio" id="separationProve0" name="separationProve" value="0" title="己开具">
                        <input type="radio" id="separationProve1" name="separationProve" value="1" title="己领取"
                               checked="">
                    </div>
                </div>
            </div>
        </div>
    </div>

    <hr/>

    <div class="layui-form-item">
        <div class="layui-input-block" id="flows">
            <button type="submit" class="layui-btn site-demo-active" lay-submit="" lay-filter="demo1">立即提交</button>
            <input type="button" id="demo3" class="layui-btn layui-btn-primary" value="取消">
        </div>
    </div>
</form>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>流程日志</legend>
</fieldset>
<ul class="layui-timeline" id="schedule">

</ul>
<script>
    var table2;
    // 修改赋值
    let pkDimissionHandoverId = getQueryString("pkDimissionHandoverId");
    layui.use(['form', 'table', 'layedit', 'laydate'], function () {
        var table = layui.table
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , form = layui.form;
        // 入职日期
        laydate.render({
            elem: '#stopPaying'
        });
        // 离职申请日期
        laydate.render({
            elem: '#payrollDeadline'
        });
        // 正式离职日期
        laydate.render({
            elem: '#paymentTime'
        });

        let res = getAjaxById(getRootPath() + "OaPersonnelAction/getUser");

        //交接人员
        $('#handoverReceiver').val(res.personnelName);
        form.render();
        
        const ress = getAjaxById(getRootPath() + "OaFlowAction/selectFlowSchedule/" + pkDimissionHandoverId);
        $("#schedule").html("");
        $.each(ress, function (index, item) {
            if (item.createdBy) {
                $("#schedule").append('<li class="layui-timeline-item">\n' +
                    '        <i class="layui-icon layui-timeline-axis"></i>\n' +
                    '        <div class="layui-timeline-content layui-text">\n' +
                    '            <h3 class="layui-timeline-title">' + dateFormat('yyyy-MM-dd hh:mm:ss', new Date(item.createdTime)) + '&nbsp;&nbsp;&nbsp;' + item.flowName + '</h3>\n' +
                    '            <p>' + item.formReason + '</p>\n' +
                    '            <p>操作人：' + item.createdBy + '</p>\n' +
                    '        </div>\n' +
                    '    </li>')

            } else {
                $("#schedule").append('<li class="layui-timeline-item">\n' +
                    '        <i class="layui-icon layui-timeline-axis"></i>\n' +
                    '        <div class="layui-timeline-content layui-text">\n' +
                    '            <h3 class="layui-timeline-title">' + dateFormat('yyyy-MM-dd hh:mm:ss', new Date(item.createdTime)) + '&nbsp;&nbsp;&nbsp;' + item.flowName + '</h3>\n' +
                    '            <p>' + item.formReason + '</p>\n' +
                    '        </div>\n' +
                    '    </li>')
            }
        });



        //监听提交
        form.on('submit(demo1)', function (data) {
            // 单击之后提交按钮不可选,防止重复提交
            var DISABLED = 'layui-btn-disabled';
            // 增加样式
            $('.site-demo-active').addClass(DISABLED);
            // 增加属性
            $('.site-demo-active').attr('disabled', 'disabled');


            let datas = {
                pkDimissionHandoverId: pkDimissionHandoverId    , // 交接人id
                handoverOfficeSupplies: $("#handoverOfficeSupplies").val(), // 办公用品说明
                handoverAccountPassword: $("#handoverAccountPassword").val(), // 公司账号
                handoverOthers: $("#handoverOthers").val(), // 其他
                attendance: $("#attendance").val(), // 本月考勤
                stopPaying: $("#stopPaying").val(), // 社保停缴时间
                payrollDeadline: $("#payrollDeadline").val(), // 薪资截止日
                paymentTime: $("#paymentTime").val()//最终工资结算及发放时间
            };
            datas.handoverRenege = $("input[name='handoverRenege'][checked]").val();//是否违约
            datas.separationProve = $("input[name='separationProve'][checked]").val();//离职证明
            let res = postAjax(getRootPath() + "/OaDimissionHandoverAction/addSection", datas);
            //console.info("调用请求");
            if (res === 1) {
                layer.msg('新增成功3秒后关闭当前窗口', {icon: 1});
                setTimeout(function () {
                    formClose();
                }, 3000);
                setTimeout(function () {
                    parent.layui.table.reload('test');//刷新父页面
                    //window.parent.location.reload();//刷新父页面
                    const index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                }, 3001);
                //window.location.reload();//刷新页面
            } else {
                layer.msg("新增失败");
            }
            return false;
        });

        $("#demo3").on("click", function () {
            //询问框
            layer.confirm('是否关闭该页面？', {
                btn: ['是的', '取消'] //按钮
            }, function () {
                formClose();
            });
        });

    });
</script>
</body>
</html>